import {LogLanguage} from "../dist/index.js"

// 测试类路径匹配要求至少一个点号
const testCases = [
  // 有效的类路径（包含点号）
  "(com.cn.yft.ora.bank.p600030.points.PointsProcessor:64)",
  "[com.cn.yft.ora.bank.sby.service.SBYBaseService]",
  " com.cn.yft.ora.bank.sby.service.SBYBaseService ",
  "(com.cn.yft.ora.bank.sby.service.SBYBaseService:87)",
  "[com.cn.yft.ora.bank.p600030.points.PointsProcessor]",
  " com.cn.yft.ora.bank.p600030.points.PointsProcessor ",
  
  // 无效的类路径（不包含点号）
  "(PointsProcessor:64)",
  "[SBYBaseService]",
  " PointsProcessor ",
  "(Service:87)",
  "[Processor]",
  " Service ",
  
  // 混合格式
  "2024-01-15 10:30:45 [INFO] (com.cn.yft.ora.bank.p600030.points.PointsProcessor:64) [com.cn.yft.ora.bank.sby.service.SBYBaseService] com.cn.yft.ora.bank.sby.service.SBYBaseService",
  
  // 复杂日志行
  "2025-08-06 11:23:02,220 INFO [TID:] [fcdfba1a21214a8e97c7d8fd1a8aa287.1161.17544505317727189] points.PointsProcessor (com.cn.yft.ora.bank.p600030.points.PointsProcessor:64) - 【权益积分通道】 积分发放"
]

console.log("=== 类路径点号要求测试 ===")

testCases.forEach((testCase, index) => {
  console.log(`\n测试 ${index + 1}:`)
  console.log(`输入: ${testCase}`)
  
  let foundClassPaths = []
  
  // 1. 检查括号包围的类路径
  const classPathRegex1 = /\(([a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+:[0-9]+)\)/g
  let match
  while ((match = classPathRegex1.exec(testCase)) !== null) {
    const from = match.index + 1  // +1 跳过左括号
    const to = from + match[1].length  // 只包含括号内的内容
    
    foundClassPaths.push({
      type: "parentheses",
      full: match[0],
      content: match[1],
      from: from,
      to: to,
      highlightedContent: testCase.slice(from, to),
      hasDot: match[1].includes('.')
    })
  }
  
  // 2. 检查方括号包围的类路径
  const classPathRegex2 = /\[([a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+)\]/g
  while ((match = classPathRegex2.exec(testCase)) !== null) {
    const from = match.index + 1  // +1 跳过左方括号
    const to = from + match[1].length  // 只包含方括号内的内容
    
    foundClassPaths.push({
      type: "brackets",
      full: match[0],
      content: match[1],
      from: from,
      to: to,
      highlightedContent: testCase.slice(from, to),
      hasDot: match[1].includes('.')
    })
  }
  
  // 3. 检查空格包围的类路径
  const classPathRegex3 = /\s([a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+)\s/g
  while ((match = classPathRegex3.exec(testCase)) !== null) {
    const from = match.index + 1  // +1 跳过前面的空格
    const to = from + match[1].length  // 只包含类路径，不包括后面的空格
    
    foundClassPaths.push({
      type: "spaces",
      full: match[0],
      content: match[1],
      from: from,
      to: to,
      highlightedContent: testCase.slice(from, to),
      hasDot: match[1].includes('.')
    })
  }
  
  if (foundClassPaths.length > 0) {
    console.log("✓ 类路径识别成功:")
    foundClassPaths.forEach(classPath => {
      console.log(`  - 类型: ${classPath.type}`)
      console.log(`  - 完整匹配: "${classPath.full}"`)
      console.log(`  - 内容: "${classPath.content}"`)
      console.log(`  - 高亮范围: ${classPath.from}-${classPath.to}`)
      console.log(`  - 高亮内容: "${classPath.highlightedContent}"`)
      console.log(`  - 包含点号: ${classPath.hasDot ? '✓' : '✗'}`)
      
      // 验证是否包含点号
      if (classPath.hasDot) {
        console.log(`  ✓ 正确: 包含点号 "${classPath.highlightedContent}"`)
      } else {
        console.log(`  ✗ 错误: 不包含点号 "${classPath.highlightedContent}"`)
      }
    })
  } else {
    console.log("✗ 未找到类路径")
  }
})
